/*
package com.socialuni.center.web.serive;

import com.socialuni.sdk.constant.AuthType;
import com.socialuni.center.web.domain.ThirdUserDODomainCreate;
import com.socialuni.center.web.manage.ThirdUserTokenDOCreate;
import com.socialuni.center.web.model.DO.user.DevAccountDO;
import com.socialuni.center.web.model.DO.oAuth.ThirdUserDO;
import com.socialuni.center.web.model.DO.oAuth.ThirdUserTokenDO;
import com.socialuni.center.web.repository.oAuth.ThirdUserTokenRepository;
import com.socialuni.center.web.utils.DevAccountUtils;
import com.socialuni.center.web.utils.model.OAuthUserROUtil;
import com.socialuni.user.model.DO.UniUserDO;
import com.socialuni.sdk.api.model.ResultRO;
import com.socialuni.social.api.OAuthApi;
import com.socialuni.sdk.constant.GenderTypeNumEnum;
import com.socialuni.model.RO.user.ApplyOAuthUserInfoRO;
import com.socialuni.model.RO.user.UserOAuthRO;
import com.socialuni.social.utils.AgeUtils;
import com.socialuni.social.utils.UserUtil;
import com.socialuni.uniapp.model.ProviderUserLoginQO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service
public class MockSocialUserLoginService1 {
    @Resource
    OAuthApi oAuthApi;
    @Resource
    OAuthService oAuthService;
    @Resource
    ThirdUserTokenRepository thirdUserTokenRepository;
    @Resource
    ThirdUserTokenDOCreate thirdUserTokenDOCreate;
    @Resource
    ThirdUserDODomainCreate thirdUserDODomainCreate;


    public ResultRO<ProviderUserLoginQO> mockSocialUserLogin(String authProvider) {
        //获取devaccount
        //获取绑定的手机号，根据手机号，获取user。然后返回这个user的信息，并且返回对应这个应用的userid
        DevAccountDO devAccountDO = DevAccountUtils.getDevAccount();
        UniUserDO socialUserDO = UserUtil.getUserByPhoneNum(devAccountDO.getPhoneNum());

        if (socialUserDO == null) {
            return new ResultRO<>("默认使用开发者账号绑定的手机号对应的清池账号进行测试，请登录清池注册后测试");
        }

        //只是记录一个授权记录
        ThirdUserDO threeUserDORO = thirdUserDODomainCreate.createThirdUserAuthDomain(devAccountDO, socialUserDO, AuthType.user);
        //授权成功
        //token有效期三个月
        //生成userToken

        ThirdUserTokenDO tokenDO = thirdUserTokenDOCreate.create(socialUserDO.getId(), devAccountDO);

        UserOAuthRO authUserRO = OAuthUserROUtil.newUserOAuthROByThreeUser(threeUserDORO, socialUserDO);
        //生成返回对象
        ApplyOAuthUserInfoRO applyOAuthUserInfoRO = new ApplyOAuthUserInfoRO();
        applyOAuthUserInfoRO.setToken(tokenDO.getToken());
        applyOAuthUserInfoRO.setUser(authUserRO);


        if (threeApplyUserInfoAuthROResultRO.hasError()) {
            return new ResultRO<>(threeApplyUserInfoAuthROResultRO);
        }
        //获取token
        ApplyOAuthUserInfoRO applyOAuthUserInfoRO = threeApplyUserInfoAuthROResultRO.getData();
        String token = applyOAuthUserInfoRO.getToken();

        ProviderUserLoginQO loginQO = new ProviderUserLoginQO();
        loginQO.setCode(token);
        UserOAuthRO userOAuthRO = applyOAuthUserInfoRO.getUser();

        loginQO.setNickName(userOAuthRO.getNickname());
        loginQO.setAvatarUrl(userOAuthRO.getAvatar());

        GenderTypeNumEnum genderTypeNumEnum = GenderTypeNumEnum.getEnumByName(userOAuthRO.getGender());
        if (genderTypeNumEnum == null) {
            genderTypeNumEnum = GenderTypeNumEnum.female;
        }
        loginQO.setGender(genderTypeNumEnum.getValue());
        loginQO.setBirthday(AgeUtils.getYearBirthDateByAge(userOAuthRO.getAge()));
        loginQO.setCity(userOAuthRO.getCity());

        //根据token 获取有用户唯一标识的用户信息
        */
/*GetOAuthUserInfoQO authVO = new GetOAuthUserInfoQO(token);
        threeApplyUserInfoAuthROResultRO = oAuthApi.getOAuthUserInfo(authVO);
        applyOAuthUserInfoRO = threeApplyUserInfoAuthROResultRO.getData();
        UserOAuthRO userOAuthRO = applyOAuthUserInfoRO.getUser();
*//*

        */
/*String platform = PlatformType.mp;
        String provider = ProviderType.social;

        //根据社交中心用户唯一标识查询，如果已注册
        Optional<UniUserAccountDO> userAccountDOOptional = socialUserAccountRepository.findByPlatformAndProviderAndUnionId(platform, provider, userOAuthRO.getUnionId());
        SocialOAuthUserRO userDetailVO;
        if (userAccountDOOptional.isPresent()) {
            UniUserAccountDO socialUserAccountDO = userAccountDOOptional.get();
            userDetailVO = SocialUserDetailModelUtil.getUserDetail(socialUserAccountDO.getUserId());
        } else {
            userDetailVO = socialUserLoginMange.createUser(platform, provider, applyOAuthUserInfoRO);
        }
        //本系统的，生成userToken，有个清池token对应集美token
        SocialUserLoginRO socialUserLoginRO = socialUserLoginService.getSocialUserLoginRO(userDetailVO);*//*

        return new ResultRO<>(loginQO);
    }
}*/
